const bodyParser = require('body-parser')
module.exports = app => {
	app.use(bodyParser.json())
	app.get('/api/list', (req, res) => {
		res.send({
			code: 200,
			data: ['a', 'b', 'c', 'd'],
			message: '数据请求成功'
		})
	})

	app.get('/api/list/123', (req, res) => {
		res.send({
			code: 200,
			data: ['a', 'b', 'c', 'd'],
			message: '数据请求成功'
		})
	})

	app.post('/api/login', (req, res) => {
		const { username, password } = req.body;

		if(username === 'admin' && password === 'admin') {
			res.send({
				code: 200,
				message: '登录成功'
			})
		} else {
			res.send({
				code: 401,
				message: '账户密码错误， 请重新登录'
			})
		}
	})
}